<%@page import="com.wanmait.cookBook.vo.Pager"%>
<%@page import="java.util.List"%>
<%@page import="com.wanmait.cookBook.vo.Cook"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%String path = request.getContextPath(); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<!-- head -->
	<jsp:include page="/front/head.jsp"></jsp:include>
	<!-- headnext-->
	<div class="w logo_wrap2" style="margin-top:10px;height:60px;padding:0;margin-bottom:10px;">
		<div class="logo_inner left">
			<a href="" title="美食天下">美食天下</a>
		</div>
		<div class="logo_current left">
			<h1><a href="" title="菜谱">菜谱</a></h1>
		</div>
		<div class="logo_search right">
		<div class="searchBox J_search"><a href="javascript:;" title="搜索" class="search_Btn J_searchBTN right" id="search">搜索</a> <input type="text" id="searchCookName" placeholder="请输入菜名" class="search_Text J_searchTxt right">
		</div>
		</div>
	</div>
	<div style="margin: 5px auto;width:990px;"><img src="<%=path %>/front/Icons/headnext.jpg" width:990px; height:90px; style="margin: 5px auto"></div>
	<!-- 显示菜谱 -->
	<style type="text/css">
		.cookList{
	width:990px;
	margin:20px auto;
	overflow:hidden;
	}
	.cookList>ul{
	width:230px;
	height:260px;
	float:left;
	margin:0px;
	padding:0px;
	margin-right:16px;
	}
	.cookList>ul>li{
	list-style:none;
	}
	</style>
	<%List<Cook> pageCook = (List<Cook>)request.getAttribute("pageCook"); %>
	<div class="cookList">
		<%for(Cook cook:pageCook){%>
			<ul>
				<li><a href="<%=path %>/ShowPersonalCookServlet?cookId=<%=cook.getId() %>"><img style="width:240px;height:240px;" src="<%=path %>/front/cookFaceImage/<%=cook.getCookPicture() %>"></a></li>
				<li><a href=""><%=cook.getCookName() %></a></li>
				<li><a href=""><%=cook.getUserinfo().getUserName() %></a></li>
			</ul>
		<%} %>
	</div>
	<!-- 页码 -->
	<style type="text/css">
		.pageNoDiv ul{
			width:990px;
			margin:20px auto;
			padding-left:400px;
			overflow:hidden;
		}
		.pageNoDiv>ul>li{
			width:30px;
			float:left;
			list-style:none;
		}
	</style>
	<%Pager pager = (Pager)request.getAttribute("pager"); %>
	<div class="pageNoDiv">
		<ul>
			<li style="width:40px;"><a href="javascript:void(0);" class="prevPageNo" style="font-size:12px;font-weight:900">上一页</a></li>
			<%for(int i=1;i<=pager.getPageCount();i++){%>
			<li style="width:40px;font-weight:900">[<a class="pageNo" style="font-size:12px;font-weight:900" href="javascript:void(0);"><%=i%></a>]</li>
			<%} %>
			<li style="width:40px;"><a href="javascript:void(0);" class="nextPageNo" style="font-size:12px;font-weight:900">下一页</a></li>
		</ul>
	</div>
	<!-- 搜索加事件 -->
	<script type="text/javascript">
	$(function(){
		$("#search").click(function(){
			var cookName = $("#searchCookName").val();//模糊搜索传文本框内容
			$.ajax({
				url:"<%=path%>/ShowAllCookServlet",
				type:"get",
				async:false,
				data:{cookName:cookName,action:"getOtherPager"},
				success:function(mes){
					
					$(".cookList").html(mes);
				}	
			});	
		});	
	});
	</script>
	<!-- 下一页 -->
	<script type="text/javascript">
		$(function(){
			$(".nextPageNo").click(function(){
				$(".PageNo").css("color","#000");
				var cookName = $("#searchCookName").val();//模糊搜索传文本框内容
				var pageNo = $(this).parent().parent().find(".pageNo").html()+1;
				$(this).parent().parent().find(".pageNo").css("color","red");
				//下一页改颜色
				if(pageNo><%=pager.getPageCount()%>)pageNo=<%=pager.getPageCount()%>;
				$.ajax({
					url:"<%=path%>/ShowAllCookServlet",
					type:"get",
					async:false,
					data:{action:"getOtherPager",pageNo:pageNo,cookName:cookName},
					success:function(mes){
						$(".cookList").html(mes);
						//改颜色
					}	
				});	
				
			});
		});
	</script>
	<!-- 上一页 -->
	<script type="text/javascript">
		$(function(){
			$(".prevPageNo").click(function(){
				var cookName = $("#searchCookName").val();//模糊搜索传文本框内容
				var pageNo = $(this).parent().parent().find(".pageNo").html()-1;
				if(pageNo<1)pageNo=1;
				$.ajax({
					url:"<%=path%>/ShowAllCookServlet",
					type:"get",
					async:false,
					data:{action:"getOtherPager",pageNo:pageNo,cookName:cookName},
					success:function(mes){
						$(".cookList").html(mes);
					}	
				});	
				
			});
		});
	</script>
	<!-- 页码 -->
	<script type="text/javascript">
		$(function(){
			$(".pageNo").click(function(){
				$(".pageNo").css("color","#000");
				var cookName = $("#searchCookName").val();//模糊搜索传文本框内容
				var pageNo = $(this).html();
				$(this).css("color","red");
				$.ajax({
					url:"<%=path%>/ShowAllCookServlet",
					type:"get",
					async:false,
					data:{action:"getOtherPager",pageNo:pageNo,cookName:cookName},
					success:function(mes){
						$(".cookList").html(mes);
					}	
				});	
			});
		});
	</script>
	<!-- footer -->
	<jsp:include page="/front/footer.jsp"></jsp:include>>
</body>
</html>